<template>
  <!-- 头部部分 -->
  <header class="header">
    <h1>todos</h1>
    <input
      v-model.trim="item"
      @keydown.enter="appendItem"
      class="new-todo"
      placeholder="请输入任务名称"
      autofocus
    />
  </header>
</template>

<script>
export default {
  data() {
    return {
      item: ""
    };
  },
  methods: {
    appendItem() {
      if (!this.item) return alert("请正确输入内容");
      this.$emit("appendItem", this.item);
      this.item = "";
    }
  }
};
</script>

<style>
</style>